<template>
  <div class="nouse">
     <ul v-if="bool" >
         <li  v-for="(v,i) in arr" :key="i">
             <div class="couleft">                            
                     <h4 class="title">订鲜花小程序{{v.pricelenth}}优惠券</h4>
                     <h2 class="price">￥<span>{{v.price}}</span></h2>
                     <h4 class="title1">鲜花满<span>{{v.firstprice}}</span>减<span>{{v.lastprice}}</span>，特价商品除外。</h4>                      
             </div>
             <div class="couright">
                 <p>当前时间</p>
                 <p class="date">{{time}}</p>
                 <input type="button" value="立即使用" class="clickuse" @click="fun()">
             </div>
         </li>
     </ul>
  </div>
</template>

<script>
import {getlink} from '@/api/getapi.js'
export default {
    data(){
        return {bool:false,
        arr:[]}
    },
    methods:{
     fun(){
         this.$router.push("/flower");
     }
    },
  
    mounted() {
    if(localStorage.getItem("coupon","coupon")){
               this.bool=true
           }
    getlink("/demo/coupons")
      .then((ok) => {
          this.arr=ok.data.coupon; 
        console.log(ok)
          
      });
    
   },

computed:{
    time:function () {
      const date = new Date();
      const year = date.getFullYear();
      const month = (date.getMonth() + 1).toString().padStart(2, 0);
      const data = date.getDate().toString().padStart(2, 0);
      const hours=date.getHours()<10 ? "0"+date.getHours() : date.getHours();
      const minutes=date.getMinutes()<10 ? "0"+date.getMinutes() : date.getMinutes();
      const seconds=date.getSeconds()<10 ? "0"+date.getSeconds() : date.getSeconds();
      return year + '-' + month + '-' + data + ' '+hours + ':' + minutes + ':' + seconds
    }
  }
}

</script>

<style scoped>
.nouse{
    background-color: #f9f9f9;
    padding: 0 0.14rem;
    font-size: 0.16rem;
}
.nouse ul li {
    width: 100%;
 /* height: 1.04rem; */
 display: flex;
 justify-content: space-between;
  padding-top: 0.16rem;
}
.couleft{
    width: 70%;  
    background-color: #ef8f46;
     height: 1rem;
     color: #ffffff;
     text-align: center;
     padding: 0.12rem 0;
     box-sizing: border-box;
     border-radius: 0.06rem;
}
.title{
font-size: 0.12rem;
}
.date{
  font-size: 0.14rem;
}
.title,.price,.title1{
    font-weight: 100;
}
.title1{
font-size:0.14rem;
}
.couright{
width: 29%;
 height: 1rem;
  background-color: #ffffff;
  padding:0.08rem 0 ;
  box-sizing: border-box;
  text-align: center;
}
.clickuse{
    width:0.8rem;
    height: 0.3rem;
    line-height: 0.3rem;
    text-align: center;
    border: 0.01rem solid #e46557;
    box-sizing: border-box;
    color:  #e46557;
    background-color: #ffffff;
    border-radius: 0.5rem;
    font-size: 0.14rem;
    /* margin-top: 0.04rem; */
}


</style>